{% extends "events.html" %}
{% load humanize %}

{% block title %}
  {{event.event_type.name}}
{% endblock title %}

{% block description %}
  {{event.event_type.name}} - {{event.level.name}} - {{event.gender.name}} - {{event.age_group.name}}.
  {% if event.completed %}
    {% for placing, meta in placings %}
      {% if placing.final_score > 0.0 %}
        {{placing.place|ordinal}} place: {{placing.competitor.first_name|lower|capfirst}} {{placing.competitor.last_name|lower|capfirst}}
      {% endif %}
    {% endfor %}
  {% endif %}
{% endblock description %}

{% block head %}
  <meta property='og:title' content='{{event.shortcode}} - CMAT 21 Scoreboard' />
  <meta property='og:description' content='{{event.event_type.name}} - {{event.level.name}} - {{event.gender.name}} - {{event.age_group.name}}.' />
{% endblock head %}

{% block right_breadcrumb %}
  <div class="pull-right">
    {{event.shortcode}}
  </div>
{% endblock right_breadcrumb %}

{% block navi_full %}{% endblock navi_full %}

{% block content_full %}
  <div class="row">
    <div class="span4"><center>
      <h1 style="text-align: center">{{event.event_type.name}}</h1><br>
      <h2 style="text-align: center">
        {{ event.level.name }} -
        {{ event.gender.name }} -
        {{ event.age_group.name }}
      </h2><br><br>
      <h2><a href="/ring/{{event.ring.number}}">Ring {{event.ring.number}}</a></h2><br>
      <h2>{{event.num_competitors}} competitors</h2>
    </center></div>
    <div class="span8">
      {% for placing, meta in placings %}
      <a href="/competitor/{{placing.competitor.last_name}}/{{placing.competitor.first_name}}">
      <div class="row">
        <div class="span2"><h3>
          {% if event.completed %}
            {% if placing.final_score > 0.0 %}
              {{placing.place|ordinal}} place
            {% else %}
              N/A
            {% endif %}
          {% else %}
            {% if placing.order %}
              {{forloop.counter|ordinal}} in line
            {% else %}
              In queue
            {% endif %}
          {% endif %}
        </h3></div>
        <div class="span2">
          <h3>
            {{placing.competitor.first_name|lower|capfirst}}
            {{placing.competitor.last_name|lower|capfirst}}
          </h3>
        </div>
        <div class="span3">
          {% if event.completed %}
            {% if placing.scores %}
              <strong>Scores:
                {% for score in meta.scores %}
                  {% if score %}
                    {% if not forloop.first %}
                      -
                    {% endif %}
                    {{score|floatformat:2}}
                  {% endif %}
                {% endfor %}
              </strong><br>
            {% endif %}
            Time:
              {%if placing.time < 10 %}
                Not available
              {% else %}
                {{placing.time}} seconds
              {% endif %}
            <br>
            {% if meta.time_deduct %}
              Time deductions: {{meta.time_deduct}}
              {% if meta.other_deduct %}
                - Other deductions: {{meta.other_deduct}}
              {% endif %}
            {% else %}
              {% if meta.other_deduct %}
                Other deductions: {{meta.other_deduct}}
              {% else %}
                No deductions
              {% endif %}
            {% endif %}
          {% endif %}
        </div>
        <div class="span1">
          {% if event.completed %}
            <h1 class="btn disabled">{{placing.final_score|floatformat:2}}</h1>
          {% endif %}
        </div>
      </div>
      </a>
      <hr />
      {% endfor %}
    </div>
  </div>
{% endblock content_full %}